#include "fwCameraManager.h"

CameraManager* CameraManager::m_pInstance = NULL;
Camera3D* CameraManager::_CurrentCamera = NULL;

CameraManager* CameraManager::GetInstance(){
	if (!m_pInstance)
		m_pInstance = new CameraManager();
	return m_pInstance;
}

void CameraManager::DestroyInstance(){
	SAFE_DEL(m_pInstance);
}

void CameraManager::RegisterCamera(const char* name, Camera3D* camera){
	std::map<const char*, Camera3D*>::iterator temp = m_lstCameras.find(name);
	if (temp != m_lstCameras.end())
		return;
	m_lstCameras[name] = camera;
}

void CameraManager::RemoveCamera(const char* name){
	std::map<const char*, Camera3D*>::iterator temp = m_lstCameras.find(name);
	if (temp == m_lstCameras.end())
		return;
	SAFE_DEL(temp->second);
	m_lstCameras.erase(name);
}

void CameraManager::FindCamera(const char* name){
	std::map<const char*, Camera3D*>::iterator temp = m_lstCameras.find(name);
	if (temp == m_lstCameras.end())
		return;
	_CurrentCamera = temp->second;
}